package com.codemeta.bokit.comm.enums;

import com.codemeta.bokit.comm.validation.InEnumKey;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 性别枚举
 *
 * @author apple
 */
@Getter
@AllArgsConstructor
public enum Sex implements InEnumKey {
    /**
     * 性别：true男性、false女性
     */
    man(true),
    woman(false);
    private final boolean value;

    /**
     * 根据int[0,1]值获取
     *
     * @param val .
     * @return .
     */
    public static Sex of(int val) {
        return val == 1 ? man : woman;
    }

    @Override
    public Set<String> keys() {
        return Arrays.stream(values()).map(s -> String.valueOf(s.isValue())).collect(Collectors.toSet());
    }
}